{smcl}
{com}{sf}{ul off}{txt}{.-}
      name:  {res}<unnamed>
       {txt}log:  {res}C:\Users\myogo\Princeton Dropbox\Motohiro Yogo\Koijen Yogo - International\JPE\Replication\Code\1 Data\SPX.smcl
  {txt}log type:  {res}smcl
 {txt}opened on:  {res} 7 Nov 2025, 15:01:58
{txt}
{com}. /* Define local and global variables */
> 
> local directory = "../../Data_nonpublic/Global Financial Data";
{txt}
{com}. do global;
{txt}
{com}. /* global.do (STATA)
>         Define global variables in "Data".
>         by Ralph Koijen & Motohiro Yogo */
. 
. #delimit ;
{txt}delimiter now ;
{com}. clear all;
{res}{txt}
{com}. global year_min = 2003;
{txt}
{com}. global year_max = 2020;
{txt}
{com}. global small = 5e-4;
{txt}
{com}.         /* Minimum reportable threshold for CPIS */

{txt}end of do-file

{com}. /* Load data */
> 
> import excel using "`directory'/SPX",
>         sheet("Price Data") first clear;
{res}{text}(4 vars, 77 obs)

{com}. drop _SPXD;
{txt}
{com}. /* Rename variables */
> 
> rename SYSPXMBM mb;
{res}{txt}
{com}. /* Construct variables */
> 
> gen int year = year(date(Date,"MDY"));
{txt}
{com}. drop Date;
{txt}
{com}. /* Construct log varialbes */
> 
> gen Lmb = ln(mb);
{txt}
{com}. /* Construct returns */
> 
> sort year;
{txt}
{com}. gen _ret = ln(_SPXTRD[_n+1]/_SPXTRD);
{txt}(1 missing value generated)

{com}. drop _SPXTRD;
{txt}
{com}. /* Sample criteria */
> 
> keep if year<=$year_max;
{txt}(2 observations deleted)

{com}. /* Label variables */
> 
> order year;
{txt}
{com}. label var year  "Year";
{txt}
{com}. label var mb    "Market-to-book equity";
{txt}
{com}. label var Lmb   "Log market-to-book equity";
{txt}
{com}. label var _ret  "Future: Return (continuously compounded)";
{txt}
{com}. /* Save data */
> 
> sort year;
{txt}
{com}. save SPX, replace;
{txt}{p 0 4 2}
file {bf}
SPX.dta{rm}
saved
{p_end}

{com}. log close;
      {txt}name:  {res}<unnamed>
       {txt}log:  {res}C:\Users\myogo\Princeton Dropbox\Motohiro Yogo\Koijen Yogo - International\JPE\Replication\Code\1 Data\SPX.smcl
  {txt}log type:  {res}smcl
 {txt}closed on:  {res} 7 Nov 2025, 15:01:58
{txt}{.-}
{smcl}
{txt}{sf}{ul off}